package com.example.home.volunteer_service.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.home.R;
import com.example.home.tool.OKHttpTool;
import com.example.home.volunteer_service.bean.VolunteerListDeatilBean;

public class VolunteerListDeatil extends AppCompatActivity {
    private ImageView back;
    private TextView title;
    private TextView undertaker;
    private TextView startAt;
    private TextView requireText;
    private TextView detail;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_volunteer_list_deatil);
        Intent intent = getIntent();
        String voluntId = intent.getStringExtra("voluntId");
        initView();

        getDetailData(voluntId);
    }

    private void getDetailData(String voluntId) {
        OKHttpTool.doNetRequest("prod-api/api/volunteer-service/activity/"+voluntId,
                OKHttpTool.GET,
                VolunteerListDeatilBean.class,
                new OKHttpTool.NetCallback() {
                    @Override
                    public void onSuccess(Object obj) {
                        VolunteerListDeatilBean volunteerListDeatilBean = (VolunteerListDeatilBean) obj;
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                VolunteerListDeatilBean.DataBean data = volunteerListDeatilBean.getData();
                                title.setText(data.getTitle());
                                undertaker.setText("承办单位："+data.getUndertaker());
                                startAt.setText("开始时间："+data.getStartAt());
                                requireText.setText("要求："+data.getRequireText());
                                detail.setText(data.getDetail());
                            }
                        });
                    }

                    @Override
                    public void onFailure(String msg) {

                    }
                });
    }

    private void initView() {

        back = findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                VolunteerListDeatil.this.finish();
            }
        });
        title = findViewById(R.id.title);
        undertaker = findViewById(R.id.undertaker);
        startAt = findViewById(R.id.startAt);
        requireText = findViewById(R.id.requireText);
        detail = findViewById(R.id.detail);

    }
}